package com.yanggu.scala.chapater11.iterator

object IteratorDemo01 {

  def main(args: Array[String]): Unit = {
    val iterator = List(1, 2, 3, 4, 5).iterator
    println("******* 遍历方式1 while *******")
    //和java一样
    while (iterator.hasNext) {
      println(iterator.next())
    }
    println("******* 遍历方式2 for ********")
    for (elem <- iterator) {
      println(elem)
    }
  }

}
